/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lib.service;

import java.io.FileNotFoundException;
import java.io.FileReader;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import lib.model.ListLib;

/**
 *
 * @author levohuutri
 */
public class XmlService {
    private static String Source = "source.xml";
    
    public static void setSource(String source) {
        Source = source;
    }
    
    public static ListLib getListLib() throws JAXBException, FileNotFoundException {
        JAXBContext context = JAXBContext.newInstance(ListLib.class);
        Unmarshaller umar = context.createUnmarshaller();
        return (ListLib) umar.unmarshal(new FileReader(Source));
    }
}
